#include <bits/stdc++.h>
using namespace std;

const int maxn = 200005;
int t;
int n;
int a[maxn];
bool color[maxn];

int ans = 0;
void dfs(int deep) {
    if (deep > n) {
        int anstt = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i-1; j >= 1; j--) {
                if (color[i] == color[j]) {
                    if (a[i] == a[j]) anstt += a[i];
                    break;
                }
            }
        }
        ans = max(ans, anstt);
    } else {
        color[deep] = 0;
        dfs(deep + 1);
        color[deep] = 1;
        dfs(deep + 1);
    }
}

int main() {
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while(t--) {
        cin >> n;
        for (int i = 1; i <= n; i++) cin >> a[i];
        memset(color, 0, sizeof(color));
        ans = 0;
        dfs(1);
        cout << ans << endl;
    }
}